package com.geez.bbl.db.type;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * User: biniam.gebremichael
 * Date: Sep 7, 2010
 */
public class SqlGenerator {


    public static String toSql(Collection<BblBook> books, String tableName) {
        StringBuilder line = new StringBuilder();
        for (BblBook book : books) {
            for (BblChapter c : book.getChapters().values()) {
                for (Verse verse : c.getVerses()) {

                    line.append("INSERT INTO ")
                            .append(tableName)
                            .append(" (book,chapter,no,no_start,no_end,Article,remark) VALUES ( ")
                            .append("'")
                            .append(book.getBook_no())
                            .append("'")
                            .append(",")
                            .append(c.getId())
                            .append(",")
                            .append(verse.getStartId())
                            .append(",")
                            .append(verse.getStartId())
                            .append(",")
                            .append(verse.getEndId())
                            .append(",")
                            .append("'")
                            .append(verse.getPlainValue())
                            .append("'")
                            .append(",")
                            .append(c.getMessage())
                            .append(");\n");


                }
            }
        }
        return line.toString();
    }
}
